
public class Button extends Component 
{
	public boolean state;
	public String label;
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public Button(String string,int x,int y) {
		state = false;
		width =  165;
		height = 25;
		this.label = string;
		this.x=x;
		this.y=y;
	}

	public void draw()
	{
		GLOBAL.processing.textFont(GLOBAL.plotFont, 14);
		int cx = x;
		int cy = y - 2;
		width = (int)(GLOBAL.processing.textWidth(label)) + 10;
		GLOBAL.processing.textAlign(GLOBAL.processing.LEFT);

		// Special cases
		if (label.equalsIgnoreCase("info") || label.equalsIgnoreCase("save") || label.equalsIgnoreCase("clear") || label.equalsIgnoreCase("top")) {
			GLOBAL.processing.strokeWeight(1);
			GLOBAL.processing.rectMode(GLOBAL.processing.CORNER);
			GLOBAL.processing.stroke(80);
			GLOBAL.processing.fill(GLOBAL.processing.color(50,50,50,255));
			GLOBAL.processing.ellipse(x, y + (float)height/2, height, height);
			GLOBAL.processing.ellipse(x+width, y + (float)height/2, height, height);
			GLOBAL.processing.noStroke();
			GLOBAL.processing.rect(x, y, width, height);
			GLOBAL.processing.stroke(80);
			GLOBAL.processing.line(x, y, x + width, y);
			GLOBAL.processing.line(x, y + height, x + width, y + height);
			
			if(state){
				GLOBAL.processing.noStroke();
				GLOBAL.processing.fill(GLOBAL.processing.color(80,80,80,255));
				GLOBAL.processing.ellipse(x, y + (float)height/2, height, height);
				GLOBAL.processing.ellipse(x+width, y + (float)height/2, height, height);
				GLOBAL.processing.rect(x, y, width, height);
			}

		}
		// Normal buttons
		else {
			if(state){
				GLOBAL.processing.rectMode(GLOBAL.processing.CORNER);
				GLOBAL.processing.noStroke();
				GLOBAL.processing.fill(120);
				GLOBAL.processing.rect(x, y, width, height);
			}

			if(mouseOver()) 
			{
				super.draw();
				if(GLOBAL.processing.mousePressed)
				{
					GLOBAL.gu.drawBox(x, y, width, height, 0, GLOBAL.processing.color(150, 150, 200), 255);
					GLOBAL.gu.drawBox(x, y, width, height, 1, GLOBAL.processing.color(150, 150, 200), 150);
					cx += 2;
					cy += 2;

				}
			}
		}
		GLOBAL.processing.strokeWeight(1);
		GLOBAL.processing.fill(GLOBAL.textColor);
		GLOBAL.processing.text(label, cx + 5, cy + 20);
	}
	public void mouseClicked(){
		state = !state;
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////

}